package com.health.db.service.user.impl;

import java.util.List;

import com.health.db.dao.user.IUserHospitalRecordDao;
import com.health.db.dao.user.IUserHospitalRecordListDao;
import com.health.db.model.UserHospitalRecord;
import com.health.db.model.UserHospitalRecordExample;
import com.health.db.service.user.IUserHospitalRecordService;

public class UserHospitalRecordServiceImpl implements IUserHospitalRecordService {
 
	IUserHospitalRecordDao userHospitalRecordDao;
	IUserHospitalRecordListDao userHospitalRecordListDao;

	@Override
	public int deleteByPrimaryKey(Long recId) {
		// TODO Auto-generated method stub
		
		int  executNum=userHospitalRecordDao.deleteByPrimaryKey(recId);
		userHospitalRecordListDao.deleteByParentKey(recId);
		return executNum;
	}

	@Override
	public int insert(UserHospitalRecordExample record) {
		// TODO Auto-generated method stub
		int  executNum= userHospitalRecordDao.insert(record);
		
	/*	String urls = record.getImgUrls();
		
		if (StringUtils.isNoneBlank(urls)) {
			
			String[] urlLit=urls.split("#");
			
			List<UserHospitalRecordList>  userHospitalRecordList =new ArrayList<UserHospitalRecordList>();
			for (int i = 0; i < urlLit.length; i++) {
				
				UserHospitalRecordList temp = new UserHospitalRecordList();
				temp.setRecordId(record.getRecId());
				temp.setImgUrl(urlLit[i]);
				userHospitalRecordList.add(temp);
			}
			userHospitalRecordListDao.insertBatch(userHospitalRecordList);
		}*/
		
		return executNum;
	}

	@Override
	public List<UserHospitalRecord> selectByExample(
			UserHospitalRecordExample example) {
		// TODO Auto-generated method stub
		return userHospitalRecordDao.selectByExample(example);
	}

	@Override
	public UserHospitalRecord selectByPrimaryKey(Long recId) {
		// TODO Auto-generated method stub
		return userHospitalRecordDao.selectByPrimaryKey(recId);
	}

	@Override
	public int updateByPrimaryKeySelective(UserHospitalRecordExample record) {
		// TODO Auto-generated method stub
		/*		userHospitalRecordListDao.deleteByParentKey(record.getRecId());
		
	String urls = record.getImgUrls();
		
		if (StringUtils.isNoneBlank(urls)) {
			
			String[] urlLit=urls.split("#");
			
			List<UserHospitalRecordList>  userHospitalRecordList =new ArrayList<UserHospitalRecordList>();
			for (int i = 0; i < urlLit.length; i++) {
				
				UserHospitalRecordList temp = new UserHospitalRecordList();
				temp.setRecordId(record.getRecId());
				temp.setImgUrl(urlLit[i]);
				userHospitalRecordList.add(temp);
			}
			userHospitalRecordListDao.insertBatch(userHospitalRecordList);
		}*/
		
		return userHospitalRecordDao.updateByPrimaryKeySelective(record);
	}

	public IUserHospitalRecordDao getUserHospitalRecordDao() {
		return userHospitalRecordDao;
	}

	public void setUserHospitalRecordDao(
			IUserHospitalRecordDao userHospitalRecordDao) {
		this.userHospitalRecordDao = userHospitalRecordDao;
	}

	public IUserHospitalRecordListDao getUserHospitalRecordListDao() {
		return userHospitalRecordListDao;
	}

	public void setUserHospitalRecordListDao(
			IUserHospitalRecordListDao userHospitalRecordListDao) {
		this.userHospitalRecordListDao = userHospitalRecordListDao;
	}

}
